package exception;

public class Test {

    public void a() {
        b();
    }

    public void b() {
        a();
    }

    static void nameFor(String name) throws AmyException {
        System.out.println("Input name:" + name);
        if(name.equals("Amy")) {
            throw new AmyException(name);
        }
    }

    public static void main(String[] args) {
        int a = 1;
        int b = 0;
        try {
            System.out.println(a/b);
        } catch (ArithmeticException e) {
            System.out.println("程序出现异常！");
        } finally {
            System.out.println("执行结束！");
        }

        try {
            new Test().a();
        } catch (Error e) {
            System.out.println("Error错误！");
        } catch (Exception e) {
            System.out.println("Exception错误！");
        }

        try {
            nameFor("Amy");
        } catch (AmyException e) {
            System.out.println("AmyException:"+e);
        }

    }

}
